package com.cw.service.impl;

import com.cw.entity.RequestLog;
import com.cw.mapper.RequestLogMapper;
import com.cw.service.IRequestLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cw.util.UUIDUtil;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 请求其他系统的记录表 服务实现类
 * </p>
 *
 * @author ly
 * @since 2021-06-22
 */
@Service
public class RequestLogServiceImpl extends ServiceImpl<RequestLogMapper, RequestLog> implements IRequestLogService {

    /**
     * 插入记录数据
     * @param requestSystem 请求的系统
     * @param requestUrl    请求的地址
     * @param requestParam  请求参数
     * @param resultParam   接口返回值
     * @param resultCode    状态编码
     * @return boolean
     * @author ly
     * @date 2021/6/22 11:02
     */
    @Override
    public boolean insertRequestLog(String requestSystem, String requestUrl, String requestParam, String resultParam, String resultCode) {
        RequestLog requestLog = new RequestLog();
        requestLog.setId(UUIDUtil.uuid());
        requestLog.setRequestSystem(requestSystem);
        requestLog.setRequestUrl(requestUrl);
        requestLog.setRequestParam(requestParam);
        requestLog.setResultParam(resultParam);
        requestLog.setResultCode(resultCode);
        requestLog.setRequestTime(LocalDateTime.now());
        return save(requestLog);
    }
}
